<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>电影列表</title>
    <%- include common %>

    <style>
        .thumbnail>img {
            height: 240px;
            width: 200px;
        }

        .thumbnail {
            cursor: pointer;
        }
    </style>
</head>

<body>
    <%- include("head",{title:"movie",username}) %>

    <div class="container-fluid">

        <h4 class="text-primary h3"><%- title %></h4>
        <div class="row" style="margin-bottom: 20px;">
            <div class="col-md-3 col-sm-6 col-xs-12">
                <button class="btn btn-primary" onclick="location.href='/movie?year=1'">
                    年份升序
                </button>
                <button class="btn btn-info" onclick="location.href='/movie?year=-1'">
                    年份降序
                </button>
                <button class="btn btn-danger" onclick="location.href='/movie?rating.average=1'">
                    评分升序
                </button>
                <button class="btn btn-warning" onclick="location.href='/movie?rating.average=-1'">
                    评分降序
                </button>
            </div>
        </div>
        <div class="row" style="margin-bottom: 20px;">
            <div class="col-md-3 col-sm-6 col-xs-12">
                <div class="form-group" style="display: flex;">
                    <input id="keyword" type="text" class="form-control" placeholder="enter keywords">
                    <button class="btn btn-danger" onclick="searchDone()">
                        电影搜索
                    </button>
                </div>
            </div>
        </div>
        <div class="row">
            <%  if(result.length>0){  %>
            <%  result.forEach((item,index)=>{  %>
            <div class="col-md-3 col-sm-6 col-xs-12">
                <a href="/comment/mdetail?mid=<%- item.id %>">
                    <div class="thumbnail">
                        <img src="<%- item.images.large.replace(/img7/,'img3') %>" alt="">
                        <div>
                            <p class="text-primary"><%- item.title %></p>
                            <p class="text-info">年份：<%- item.year %></p>
                            <p class="text-danger">评分：<%- item.rating.average %></p>
                            <p class="text-warning">分类：<%- item.genres %></p>
                        </div>
                    </div>
                </a>
            </div>
            <%  })  %>
            <%  }else{  %>
            <p class="text-center text-danger">暂无数据</p>
            <%  }  %>
        </div>
    </div>
    <%- include("foot") %>

</body>
<script>
    function searchDone() {
        location.href = '/movie?keyword=' + $("#keyword").val()
    }
</script>

</html>